home *** CD-ROM | disk | FTP | other *** search
- # This file is a Tcl script to test out the code in tkImgFmtPPM.c,
- # which reads and write PPM-format image files for photo widgets.
- # The files is organized in the standard fashion for Tcl tests.
- #
- # Copyright (c) 1994 Sun Microsystems, Inc.
- #
- # See the file "license.terms" for information on usage and redistribution
- # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- #
- # @(#) imgPPM.test 1.3 95/06/08 17:04:46
-
- if {[info procs test] != "test"} {
- source defs
- }
-
- foreach i [winfo children .] {
- destroy $i
- }
- wm geometry . {}
- raise .
-
- eval image delete [image names]
-
- proc put {file data} {
- set f [open $file w]
- puts -nonewline $f $data
- close $f
- }
-
- test ppm-1.1 {FileReadPPM procedure} {
- put test.ppm "P6\n0 256\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
- test ppm-1.2 {FileReadPPM procedure} {
- put test.ppm "P6\n-2 256\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
- test ppm-1.3 {FileReadPPM procedure} {
- put test.ppm "P6\n10 0\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
- test ppm-1.4 {FileReadPPM procedure} {
- put test.ppm "P6\n10 -2\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {PPM image file "test.ppm" has dimension(s) <= 0}}
- test ppm-1.5 {FileReadPPM procedure} {
- put test.ppm "P6\n10 10\n255\nabcdef"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {error reading PPM image file "test.ppm": not enough data}}
- test ppm-1.6 {FileReadPPM procedure} {
- put test.ppm "P6\n5 4\n255\n01234567890123456789012345678901234567890123456789012345678"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {error reading PPM image file "test.ppm": not enough data}}
- test ppm-1.7 {FileReadPPM procedure} {
- put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg \
- [image width p1] [image height p1]
- } {0 p1 5 4}
-
- catch {image delete p1}
- put test.ppm "P6\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- image create photo p1 -file test.ppm
- test ppm-2.1 {FileWritePPM procedure} {
- list [catch {p1 write foo/bar/baz/gorp} msg] [string tolower $msg] \
- [string tolower $errorCode]
- } {1 {foo/bar/baz/gorp: no such file or directory} {posix enoent {no such file or directory}}}
- test ppm-2.2 {FileWritePPM procedure} {
- p1 write test2.ppm
- exec cat test2.ppm
- } {P6
- 5 4
- 255
- 012345678901234567890123456789012345678901234567890123456789}
-
- test ppm-3.1 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "# \n#\n#\nP6\n#\n##\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {0 p1}
- test ppm-3.2 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\n5\n 4 255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {0 p1}
- test ppm-3.3 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\n# asdfasdf\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {0 p1}
- test ppm-3.4 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6 \n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {0 p1}
- test ppm-3.5 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P5\n5 4\n255\n01234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {0 p1}
- test ppm-3.6 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P3\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
- test ppm-3.7 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6x\n5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
- test ppm-3.8 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\nxy5 4\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
- test ppm-3.9 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\n5\n255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
- test ppm-3.10 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\n5 4\nzz255\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
- test ppm-3.11 {ReadPPMFileHeader procedure} {
- catch {image delete p1}
- put test.ppm "P6\n5 4\n254\n012345678901234567890123456789012345678901234567890123456789"
- list [catch {image create photo p1 -file test.ppm} msg] $msg
- } {1 {couldn't recognize data in image file "test.ppm"}}
-
-
- catch {exec rm test.ppm}
- catch {exec rm test2.ppm}
- eval image delete [image names]
-